import {
    graphql,
    GraphQLSchema,
    GraphQLObjectType,
    GraphQLString,
    GraphQLList,
    GraphQLNonNull,
    GraphQLBoolean,
    GraphQLInt

} from 'graphql';

import Role_jurisdiction_temp from '../../db/models/role_jurisdiction_temp'

export let tempType = new GraphQLObjectType({
    name: 'temp',
    fields: {
        id: {
            type: GraphQLInt
        },
        role_id: {
            type: GraphQLInt
        },
        jurisdiction_id: {
            type: GraphQLInt
        }
    }
})

export const Role_jurisdiction_By_Role = {
    type: new GraphQLList(tempType),
    args: {
        role_id: {
            type: GraphQLInt
        }
    },
    resolve(root, params, options) {
        return Role_jurisdiction_temp.findAll({
            where: {
                role_id: params.role_id
            }
        })
    }
}

export const Role_jurisdiction_By_jurisdiction = {
    type: new GraphQLList(tempType),
    args: {
        jurisdiction_id: {
            type: GraphQLInt
        }
    },
    resolve(root, params, options) {
        return Role_jurisdiction_temp.findAll({
            where: {
                jurisdiction_id: params.jurisdiction_id
            }
        })
    }
}
